namespace Kairos.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Documents",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Contenu = c.String(nullable: false),
                        MetaData_1ID = c.Int(nullable: false),
                        MetaData_2ID = c.Int(nullable: false),
                        Titre = c.String(nullable: false),
                        DateCreation = c.DateTime(nullable: false),
                        DateModification = c.DateTime(nullable: false),
                        DateExpiration = c.DateTime(nullable: false),
                        UserCreation = c.String(),
                        UserModification = c.String(),
                        Revision = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.MetaData1", t => t.MetaData_1ID)
                .ForeignKey("dbo.MetaData2", t => t.MetaData_2ID)
                .Index(t => t.MetaData_1ID)
                .Index(t => t.MetaData_2ID);
            
            CreateTable(
                "dbo.MetaData1",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Nom = c.String(nullable: false),
                        Expiration = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.MetaData2",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Nom = c.String(nullable: false),
                        Expiration = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Graphes",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        ImageID = c.Int(nullable: false),
                        Titre = c.String(nullable: false),
                        DateCreation = c.DateTime(nullable: false),
                        DateModification = c.DateTime(nullable: false),
                        DateExpiration = c.DateTime(nullable: false),
                        UserCreation = c.String(),
                        UserModification = c.String(),
                        Revision = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Images", t => t.ImageID)
                .Index(t => t.ImageID);
            
            CreateTable(
                "dbo.Images",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        ContentLength = c.Int(nullable: false),
                        ContentType = c.String(),
                        FileName = c.String(),
                        Data = c.Binary(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Mappages",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Titre = c.String(nullable: false),
                        Position = c.String(nullable: false),
                        Lien = c.String(nullable: false),
                        GrapheID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Graphes", t => t.GrapheID)
                .Index(t => t.GrapheID);
            
            CreateTable(
                "dbo.Vtoms",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Titre = c.String(nullable: false, maxLength: 50,
                            annotations: new Dictionary<string, AnnotationValues>
                            {
                                { 
                                    "Collation",
                                    new AnnotationValues(oldValue: null, newValue: "French_CS_AS")
                                },
                            }),
                        Variables = c.String(),
                        DocID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Documents", t => t.DocID)
                .Index(t => t.Titre, unique: true)
                .Index(t => t.DocID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Vtoms", "DocID", "dbo.Documents");
            DropForeignKey("dbo.Mappages", "GrapheID", "dbo.Graphes");
            DropForeignKey("dbo.Graphes", "ImageID", "dbo.Images");
            DropForeignKey("dbo.Documents", "MetaData_2ID", "dbo.MetaData2");
            DropForeignKey("dbo.Documents", "MetaData_1ID", "dbo.MetaData1");
            DropIndex("dbo.Vtoms", new[] { "DocID" });
            DropIndex("dbo.Vtoms", new[] { "Titre" });
            DropIndex("dbo.Mappages", new[] { "GrapheID" });
            DropIndex("dbo.Graphes", new[] { "ImageID" });
            DropIndex("dbo.Documents", new[] { "MetaData_2ID" });
            DropIndex("dbo.Documents", new[] { "MetaData_1ID" });
            DropTable("dbo.Vtoms",
                removedColumnAnnotations: new Dictionary<string, IDictionary<string, object>>
                {
                    {
                        "Titre",
                        new Dictionary<string, object>
                        {
                            { "Collation", "French_CS_AS" },
                        }
                    },
                });
            DropTable("dbo.Mappages");
            DropTable("dbo.Images");
            DropTable("dbo.Graphes");
            DropTable("dbo.MetaData2");
            DropTable("dbo.MetaData1");
            DropTable("dbo.Documents");
        }
    }
}
